<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;



class TestController extends Controller
{
    //
    public function index()
    {


        //写入待发送记录
        $msgRule = DB::table('msg_rules')
                    ->where('type','=',1)
                    ->get();
        $msgLogArray = array();
        $now = date("Y-m-d H:i:s",time());
        foreach($msgRule as $v){
            //计算发送时间
            $min = $v->minute;
            $sendTime = date('Y-m-d H:i:s',strtotime("$now+$min min"));
            $msgLogArray[] = ['sendtime'=>$sendTime,'msg'=>$v->msg,'created_at'=>$now,'updated_at'=>$now];
        }
        DB::table('msg_logs')->insert($msgLogArray);
    }
}
